package cn.dakaqi.utils;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by chunyang on 2016/5/29.
 */
@Component
@Transactional
public class BaseDAO
{
    @Autowired
    DruidDataSource dataSource;

    JdbcTemplate jt = null;

    public BaseDAO()
    {

    }
    private void init()
    {
        jt = new JdbcTemplate(this.dataSource);
    }
    public List queryNativeSql(String sql)
    {
        init();
        return jt.queryForList(sql);
    }
    public int updateNativeSql(String sql)
    {
        init();
        return jt.update(sql);
    }
}
